# -*-coding = utf-8 -*-

# @Time: 2021/4/20 17:42
# @Author: bistro
# @File: p27.py
# @Software: PyCharm
# 27. 移除元素
from typing import List


class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        n = len(nums)
        if n == 0:
            return 0
        i = 0
        for j in range(n):
            if nums[j] != val:
                nums[i] = nums[j]
                i += 1
        return i
